class Solution {
    public static int minSubArrayLen(int target, int[] nums) {
        int left = 0,right = 0,length = 0,len = 0,sum = 0;
        while(right < nums.length && left < nums.length) {
            sum += nums[right++];
            len++;
            while(sum >= target) {
                if(length == 0 || length > len) {
                    length = len;
                }
                sum -= nums[left];
                left++;
                len--;
            }
        }
        return length;
    }

    public static void main(String[] args) {
        int[] arr = {1,1,1,1,1,1};
        int n = minSubArrayLen(11,arr);
        System.out.println(n);
    }
}